package com.hqyj.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hqyj.pojo.UserInfo;
import org.apache.ibatis.annotations.*;

/**
 * 项目:demo-springboot-230701
 * 描述:
 * 时间:2023/9/26 10:38
 * 作者:admin
 * 版本:1.0
 **/
public interface UserInfoDao extends BaseMapper<UserInfo> {


    //一对一分页查询 注解
    @Select("select * from user_info where user_id > #{user.userId} ")
    @Results(id = "baseResultMap",value = {
            @Result(column = "user_id",property = "userId"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "user_pwd",property = "userPwd"),
            @Result(column = "user_salt",property = "userSalt"),
            @Result(column = "user_detail_id",property = "userDetail",
            one = @One(select = "com.hqyj.dao.UserDetailDao.selectById")),
    })
    Page<UserInfo> selectOneAndMany(Page<UserInfo> page,@Param("user") UserInfo userInfo);
    //一对一分页查询 sqlXMl版本
    Page<UserInfo> selectOneAndManyXml(Page<UserInfo> page,@Param("user") UserInfo userInfo);

    //一对多的分页查询  注解
    @Select("select * from user_info  ")
    @Results(id = "baseResultMap02",value = {
            @Result(column = "user_id",property = "userId"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "user_pwd",property = "userPwd"),
            @Result(column = "user_salt",property = "userSalt"),
            @Result(column = "user_id",property = "list",
                    many = @Many(select = "com.hqyj.dao.OrderInfoMapper.selectListByUserId")),
    })
    Page<UserInfo> selectMany(Page<UserInfo> page,@Param("user") UserInfo userInfo);


}
